package com.junchao.peng.controller;

import com.junchao.peng.mapper.MessageMapper;
import com.junchao.peng.pojo.Message;
import com.junchao.peng.utils.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author dell
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Resource
    MessageMapper messageMapper;

    @ApiOperation("通知列表")
    @GetMapping("/listMessage")
    public JsonResult listMessage(){
        return new JsonResult(messageMapper.listMessage());
    }

    @ApiOperation("某个通知")
    @GetMapping("/selectMessageById")
    JsonResult selectMessageById(Integer id){
        return new JsonResult(messageMapper.selectMessageById(id));
    }

    @ApiOperation("新建通知")
    @PostMapping("/insertMessage")
    JsonResult insertMessage(Message message){
        return new JsonResult(messageMapper.insertMessage(message));
    }
}
